package com.survey.Controller;

import com.survey.pojo.data.AdminDO;
import com.survey.pojo.vo.AdminVO;
import com.survey.service.AdminService;
import com.survey.utils.DataUtils;
import com.survey.utils.PageBean;
import com.survey.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/admin")
public class AdminManagerController {

    @Autowired
    AdminService adminService;

    @RequestMapping("/adminList")
    public String list(AdminVO adminVO, String pageCode, HttpSession session) throws Exception {
        adminVO.setPageCode(DataUtils.getPageCode(pageCode));
        adminVO.setPageSize(10);
        adminVO.setSize(5);
        PageBean<AdminDO> pageBean = adminService.adminListManager(adminVO);
        session.setAttribute("pageBean", pageBean);
        return "/admin/AdminList.jsp";
    }

    @RequestMapping("/delete")
    @ResponseBody
    public Result delete(AdminVO adminVO) throws Exception {
        System.out.println(adminVO);
       return adminService.deleteAdmin(adminVO);
    }


}
